package my.magic.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class Parent extends Activity{
	
	protected LinearLayout buttonBild;
	protected LinearLayout buttonManu;
	protected LinearLayout buttonLPZaehler;
	protected LinearLayout buttonWantz;
	protected RelativeLayout background;
	protected String activityName;
	
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
		fullscreen();
		super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        activityName ="Hauptmenue";
        setID();
        buttonAction(this.activityName);
        
	}
	
	
	public void fullscreen(){
		requestWindowFeature(Window.FEATURE_NO_TITLE);                     //Vollbild aktivieren
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   //Vollbild aktivieren
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);  //Vollbild aktivieren
	}
	
	public void setID(){
		buttonBild= (LinearLayout) findViewById(R.id.buttonBild);
        buttonManu= (LinearLayout) findViewById(R.id.buttonManu);
        buttonLPZaehler= (LinearLayout) findViewById(R.id.buttonLpzaehler);
        buttonWantz= (LinearLayout) findViewById(R.id.buttonWantz);
        background= (RelativeLayout) findViewById(R.id.background);
	}
	
	
	public void buttonAction(String name){
		if (name != "Bilderkennung"){
			buttonBild.setOnClickListener(new View.OnClickListener() {
	            @Override
				public void onClick(View v) {
	                Intent myIntent = new Intent(v.getContext(), PictureRecog.class);
	                startActivity(myIntent);
	            }
	        });
		}else{
			buttonBild.setOnClickListener(new View.OnClickListener() {
	            @Override
				public void onClick(View v) {
	                Intent myIntent = new Intent(v.getContext(), Parent.class);
	                startActivity(myIntent);
	            }
	        });
		}
		
		
		if (name != "Manuelle Suche"){
			buttonManu.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent myIntent = new Intent(v.getContext(), ManuSearch.class);
					startActivity(myIntent);
				}
			});
		}else{
			buttonManu.setOnClickListener(new View.OnClickListener() {
	            @Override
				public void onClick(View v) {
	                Intent myIntent = new Intent(v.getContext(), Parent.class);
	                startActivity(myIntent);
	            }
	        });
		}
		
		if (name != "LPZaehler"){
			buttonLPZaehler.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent myIntent = new Intent(v.getContext(), LPzaehler.class);
					startActivity(myIntent);
				}
			});
		}else{
			buttonLPZaehler.setOnClickListener(new View.OnClickListener() {
	            @Override
				public void onClick(View v) {
	                Intent myIntent = new Intent(v.getContext(), Parent.class);
	                startActivity(myIntent);
	            }
	        });
		}
		
		if (name != "Wantliste"){
			buttonWantz.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent myIntent = new Intent(v.getContext(), Wantzlist.class);
					startActivity(myIntent);
				}
			});
		}else{
			buttonWantz.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent myIntent = new Intent(v.getContext(), Parent.class);
	                startActivity(myIntent);
				}
			});
		}
	}
}